<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据代理</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<script type="text/javascript">
    let number = 18;
    let person = {
        name: '张三',
        sex: 'man',
        // age: number
    }

    Object.defineProperty(person, 'age', {
        // value: 18,
        // enumerable: true,  //控制属性是否可以被枚举
        // writable: true,  //控制属性是否可以被修改
        // configurable: true  //控制属性是否可以被删除

        get() {
            console.log('有人读取了age');
            return number;
        },
        set(value) {
            console.log('有人设置了age，值为age：' + value);
            number = value;
        },

    })

    Object.keys(i in person);

    console.log(person);

</script>

</body>
</html>
